/*
 * @Author: CtrlC
 * @Date: 2022-07-26 17:00:14
 * @LastEditors: Please set LastEditors
 * @LastEditTime: 2024-07-10 15:27:45
 * @Description: file content
 * @FilePath: /vue3-uniapp-engineering/vite.config.js
 */
import { defineConfig } from 'vite'
import uni from '@dcloudio/vite-plugin-uni'
import tailwindcss from 'tailwindcss'
import commonjs from '@rollup/plugin-commonjs' //引入commojs
import requireTransform from 'vite-plugin-require-transform' //引入require
import path from 'path'
// https://vitejs.dev/config/
export default defineConfig({
  resolve: {
    alias: {
      'uview-plus': path.resolve(__dirname, 'node_modules/uview-plus')
    }
  },
  plugins: [
    uni(),
    commonjs(), // 添加 commonjs 插件
    requireTransform({
      fileRegex: /.js$|.vue$|.png$|.ts$|.jpg$/
    }) // 添加 require-transform 插件
    // eslintPlugin({
    //   cache: false
    // })
  ],
  css: {
    postcss: {
      // 内联写法
      plugins: [tailwindcss()]
    },
    preprocessorOptions: {
      scss: {
        // 取消sass废弃API的报警
        silenceDeprecations: ['legacy-js-api', 'color-functions', 'import']
      }
    }
  },
  build: {
    rollupOptions: {
      external: ['uview-plus/components/**/*', 'uview-plus/theme.scss']
    }
  }
})
